package team.knowers.qzh.qzhadmin.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import team.knowers.qzh.qzhadmin.config.convention.result.Result;
import team.knowers.qzh.qzhadmin.config.convention.result.Results;
import team.knowers.qzh.qzhadmin.dto.req.PageUserReqDTO;
import team.knowers.qzh.qzhadmin.dto.resp.PageUserMessageRespDTO;
import team.knowers.qzh.qzhadmin.dto.resp.UserMessageRespDTO;
import team.knowers.qzh.qzhadmin.service.UserAdminService;

@RestController
@RequiredArgsConstructor
public class UserAdminController {
    private final UserAdminService userAdminService;

    /**
     * 封禁用户
     */
    @PutMapping("/api/qzh-admin/admin/v1/grame/ban/{username}")
    public Result<String> ban(@PathVariable("username") String username) {
        return Results.success(userAdminService.ban(username));
    }

    /**
     * 用户解封
     */
    @PutMapping("/api/qzh-admin/admin/v1/grame/relieve/{username}")
    public Result<String> relieve(@PathVariable("username") String username) {
        return Results.success(userAdminService.relieve(username));
    }
    /**
     * 展示用户
     */
    @PutMapping("/api/qzh-admin/admin/v1/user/show")
    public Result<IPage<PageUserMessageRespDTO>> showUser(@RequestBody PageUserReqDTO req){
        return Results.success(userAdminService.showUser(req));
    }
    /**
     * 查询创作者创作
     */
    @GetMapping("/api/qzh-admin/admin/v1/show/{username}")
    public Result<UserMessageRespDTO> showUser(@PathVariable("username")String username){
        return Results.success(userAdminService.showUser(username));
    }
}
